/**
 * @file    Boot_param.h
 * @brief   BOOT参数管理
 * @author  Liuwei
 * @version 1.0.1
 * @date    2023-05-08
 * 
 * @copyright Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version   <th>Author   <th>Description
 * <tr><td>2023-05-08 <td>1.0.1     <td>Liuwei   <td>首次创建
 * </table>
 */
#ifndef __BOOT_PARAM_H_
#define __BOOT_PARAM_H_

/* file includes -------------------------------------------------------------*/
#include <stdint.h>
/* cplusplus -----------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif

/* macro/define/typedef ------------------------------------------------------*/
#define BOOT_PAR_ADDR    (0x7000)
#define BOOT_MD5_ADDR    (0x7800)
#define BOOT_PAR_VAR     (1)
#define BOOT_VERSION     (1)

#define BOOT_UPGRADE_EMS      (0xA1)
#define BOOT_UPGRADE_PRALLEL  (0xA2)
#define BOOT_UPGRADE_PCS      (0xA3)
#define BOOT_UPGRADE_LCD      (0xA4)
#define BOOT_UPGRADE_BLUE     (0xA5)
#define BOOT_UPGRADE_RS232    (0xA6)
#define BOOT_UPGRADE_GPS      (0xA7)

#define BOOT_UPGRADE_CAN1     (0xB1)
#define BOOT_UPGRADE_CAN2     (0xB2)

#define UART1_DEF_SPEED  (38400)
#define UART2_DEF_SPEED  (38400)
#define UART3_DEF_SPEED  (38400)
#define UART4_DEF_SPEED  (38400)
#define UART5_DEF_SPEED  (38400)
#define UART6_DEF_SPEED  (38400)
#define UART_DEF_SPEED   (38400)

#define CAN_SEPEED_125K   (500)
#define CAN_SEPEED_250K   (500)
#define CAN_SEPEED_500K   (500)
#define CAN_SEPEED_1000K  (1000)

#define CAN1_DEF_SPEED  (CAN_SEPEED_250K)
#define CAN2_DEF_SPEED  (CAN_SEPEED_500K)
#define CAN_DEF_SPEED   (CAN_SEPEED_500K)

#define BOOT_PAR_SIZE   (32)

enum
{
    BP_ID_PAR_VER   , /*!< (000)版本参数*/
	BP_ID_UPGRADE_FLAG , /*!< (001) 升级标志位 */
    BP_ID_BOOT_VER  , /*!< (002)BOOT版本*/
    BP_ID_PARALLEL_RATE , /*!< (003)COM1波特率*/
    BP_ID_PCS_RATE , /*!< (004)COM2波特率*/
    BP_ID_LCD_RATE , /*!< (005)COM3波特率*/
    BP_ID_BLUE_RATE , /*!< (006)COM4波特率*/
    BP_ID_RS232_RATE , /*!< (007)COM5波特率*/
    BP_ID_GPS_RATE , /*!< (008)COM6波特率*/
    BP_ID_CAN1_SPEED , /*!< (009)CAN1波特率*/
    BP_ID_CAN2_SPEED , /*!< (010)CAN2波特率*/
	BP_ID_RESET_FLAG , /*!< (011)复位状态 */
	BP_ID_APP_SIZE   , /*!< (012)APP大小 */
	BP_ID_APP_CRC    , /*!< (013)APP校验码 */
};

/* @brief */

/* variables -----------------------------------------------------------------*/

/*******************************************************************************
 * public API List
 ******************************************************************************/
void boot_par_init(void);
uint32_t boot_param_read_md5(uint8_t par_id);
uint32_t boot_param_read_par(uint8_t par_id);
void boot_param_set_par(uint8_t par_id , uint32_t par_val);
void boot_param_app_write(uint8_t com_id);
void boot_clear_upgrade_flag(void);
void boot_param_write_reset(void);
void boot_clear_reset_flag(void);
uint8_t boot_param_is_upgrade(void);

#ifdef __cplusplus
}
#endif

#endif  /* #ifndef __BOOT_PARAM_H_ */
/********** Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD *********/
